<?php

namespace app\portal\controller;

use cmf\controller\AdminBaseController;
use think\Db;
use app\portal\model\UserFavoriteModel;
use app\portal\model\UserHousePasswordModel;
use app\portal\model\HouseRecord;

class AdminHouseCountController extends AdminBaseController
{

  public function connect () {
    $id = input('id', false);
    if (!$id) {
      exit('<h1>参数不正确</h1>');
    }

    $data = HouseRecord::where('house_id', $id)->where('type_name', 'connect')->paginate(10);

    $this->assign('data', $data);
    return $this->fetch();
  }

  public function collection () {
    $id = input('id', false);
    if (!$id) {
      exit('<h1>参数不正确</h1>');
    }

    $data = UserFavoriteModel::with('user')->where('table_name', 'houses')->where('object_id', $id)->paginate(10);

    $this->assign('data', $data);
    return $this->fetch();
  }

  public function unlock () {
    $id = input('id', false);
    if (!$id) {
      exit('<h1>参数不正确</h1>');
    }

    $data = HouseRecord::where('house_id', $id)->where('type_name', 'unlock')->paginate(10);

    $this->assign('data', $data);
    return $this->fetch();
  }

}
